﻿using System;
using System.Collections.Generic;
using System.ComponentModel.Design;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.SqlClient;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string connectionString = "server=.;database=GS;uid=sa;pwd=8812345";
                SqlConnection sqlConnection = new SqlConnection(connectionString);
                 sqlConnection.Open();
            var SqlCommandString = "Select * from emp";
            SqlCommand sqlCommand = new SqlCommand(SqlCommandString, sqlConnection);
            var sdr = sqlCommand.ExecuteReader();
            Console.WriteLine("{0}\t{1}\t{2}", "姓名", "性别", "年龄");
            while (sdr .Read())
            {
                Console.WriteLine("{0}\t{1}\t{2}", sdr["ename"], sdr["age"], sdr["sex"]);
            }
            sqlConnection.Close();
        }
    }
}
